﻿@{
    ViewBag.Title = "Index";
}

<div class="bs-table-toolbar" @*data-buttons-del="true"*@>

</div>
<table class="table">
</table>

@section styles{
    @Styles.Render("~/Content/bootstrapTable")
}
@section scripts{
    @Scripts.Render("~/bundles/jqueryExport")
    @Scripts.Render("~/bundles/bootstrapTable")
    <script type="text/javascript">
        $.bsTable({
            url: "/ArticleType/Select",
            bsToolbar: {
                events: function ($sender, type, ids) {
                    if (type === "click") {
                        if ($sender.hasClass("delete")) {
                            if (ids.length > 0) {
                                //在这里写删除功能
                                console.log("删除选中数据id:" + ids);
                            } else {
                                console.log("请先选择数据");
                            }
                        }
                    }
                },
                buttons: {
                    insert: {
                        click: {
                            title: "添加文章分类",
                            action: "/Admin/ArticleType/Insert"
                        }
                    },
                    delete: {
                        click: {
                            action: "/Admin/ArticleType/Delete"
                        }
                    }
                }
            },
            bsColumn: {
                operate: {
                    column: {
                        buttons: {
                            delete: {
                                click: {
                                    action: "/Admin/ArticleType/Delete"
                                }
                            },
                            update: {
                                click: {
                                    title: "修改文章类型",
                                    action: "/Admin/ArticleType/Update"
                                }
                            },
                            detail: {
                                click: {
                                    title: "文章分类详情",
                                    action: "/Admin/ArticleType/Detail"
                                }
                            }
                        }
                    }
                }
            },
            tableEvents: tableClick,
            columns: [
                {
                    field: 'id',
                    title: '编号'
                },
                {
                    field: 'name',
                    title: '分类名称',
                },
                {
                    field: 'count',
                    title: '文章数量',
                },
                {
                    field: 'isDeleted',
                    title: '是否删除',
                },
                {
                    field: 'createTime',
                    title: '添加时间',
                }
            ]
        })



        function tableClick($sender, type, $row, id) {
            if (type === "click") {
                if ($sender.hasClass("delete")) {
                    console.log("删除id:" + id);
                    $row.remove();
                }
                if ($sender.hasClass("update")) {
                    console.log("修改id:" + id);
                }
            }
            console.log(arguments);
        }
    </script>
}

